package com.ruoyi.web.controller.cinema;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.cinema.domain.FilmStill;
import com.ruoyi.cinema.service.IFilmStillService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 影片剧照Controller
 *
 * @author HHAOYU
 * @date 2020-12-07
 */
@RestController
@RequestMapping("/cinema/filmStill")
public class FilmStillController extends BaseController
{
    @Autowired
    private IFilmStillService filmStillService;

    /**
     * 查询影片剧照列表
     */
    @PreAuthorize("@ss.hasPermi('cinema:filmStill:list')")
    @GetMapping("/list")
    public TableDataInfo list(FilmStill filmStill)
    {
        startPage();
        List<FilmStill> list = filmStillService.selectFilmStillList(filmStill);
        return getDataTable(list);
    }

    /**
     * 导出影片剧照列表
     */
    @PreAuthorize("@ss.hasPermi('cinema:filmStill:export')")
    @Log(title = "影片剧照", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(FilmStill filmStill)
    {
        List<FilmStill> list = filmStillService.selectFilmStillList(filmStill);
        ExcelUtil<FilmStill> util = new ExcelUtil<FilmStill>(FilmStill.class);
        return util.exportExcel(list, "filmStill");
    }

    /**
     * 获取影片剧照详细信息
     */
    @PreAuthorize("@ss.hasPermi('cinema:filmStill:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(filmStillService.selectFilmStillById(id));
    }

    /**
     * 新增影片剧照
     */
    @PreAuthorize("@ss.hasPermi('cinema:filmStill:add')")
    @Log(title = "影片剧照", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FilmStill filmStill)
    {
        return toAjax(filmStillService.insertFilmStill(filmStill));
    }

    /**
     * 修改影片剧照
     */
    @PreAuthorize("@ss.hasPermi('cinema:filmStill:edit')")
    @Log(title = "影片剧照", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FilmStill filmStill)
    {
        return toAjax(filmStillService.updateFilmStill(filmStill));
    }

    /**
     * 删除影片剧照
     */
    @PreAuthorize("@ss.hasPermi('cinema:filmStill:remove')")
    @Log(title = "影片剧照", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(filmStillService.deleteFilmStillByIds(ids));
    }
}
